
package com.probiz.estore.customer.service;

import java.util.List;
import java.util.Map;

import com.probiz.estore.common.model.customer.Membership;
import com.probiz.estore.core.service.GenericManager;
import com.probiz.estore.eai.customerclass.generated.CustomerClass;

/**
 * Membership Business Delegate (Proxy) Interface to handle communication
 * between web and persistence layer. Developer introduced interfaces should be
 * declared here. Won't get overwritten.
 * 
 */
public interface MembershipManager extends GenericManager<Membership> {
	
	/**
	 * 完全保存方法
	 * @param membership
	 * @return
	 */
	public Map<String, Object> saveFully(Membership membership);
	/**
	 * 完全删除方法，会把关联到的会员自动设置为前一等级
	 * @param membership
	 * @return
	 */
	public Map<String, Object> deleteFully(Membership membership);
	/**
	 * 获得比该等级更低的会员等级实体
	 * @param level
	 * @return
	 */
	public Membership getLowerLevelMembership(Integer level);
	/**
	 * 获得比该等级更高的会员等级实体
	 * @param level
	 * @return
	 */
	public Membership getHigherLevelMembership(Integer level);
	/**
	 * 获得默认会员等级
	 * @return
	 */
	public Membership getBaseMembership();
	/**
	 * 根据会员等级名称获得会员等级实体
	 * @param name
	 * @return
	 */
	public List<Membership> getMembershipByName(String name);
	/**
	 * 根据会员等级level获得会员等级实体
	 * @param level
	 * @return
	 */
	public Membership getMembershipByLevel(Integer level);

	/**
	 * 判断不是membershipId，但相同level的等级是否存在
	 * @param membershipId
	 * @param level
	 * @return
	 */
	public boolean isLevelExist(Integer membershipId, Integer level);

	/**
	 * 获得所有会员等级，并根据指定的等级升降序排序
	 * @param isAsc 是否升序排序
	 * @return
	 */
	public List<Membership> getAllMembershipsOrderByLevel(boolean isAsc);

	 /**
	  * 升级的积分是否有效。
	  * 保证会员资格等级越高升级积分越多的规则. 只有0或1条记录满足时是可以修改的.
	  * 例如会员资格等级和升级积分分别有普通会员:1,500,高级VIP:3,3000.此时要插入VIP:2,1000的话,
	  * 要判断2>1并升级积分1000>500.
	  * @param membership
	  * @return
	  */
	public boolean isUpgradeShopPointValid(Membership membership);

	

	// for eai
	public void doImportMebershipsForEai(List<CustomerClass> customerClassList);

	public Membership getMembershipByCode(String membershipCode);
}
